package com.yupi.springbootinit.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Value("${pikimbi.userPath}")
    private String userPath;

    @Value("${pikimbi.picturePath}")
    private String picturePath;

    //配置资源真实路径
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/imgPikimbi/user/**")
                .addResourceLocations("file:" + userPath);
        registry.addResourceHandler("/imgPikimbi/pictureGenerate/**")
                .addResourceLocations("file:" + picturePath);
    }

}
